using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Xna.Framework;

namespace HappySprite.Tests
{
    [TestClass]
    public class QuaternionExtensionsTests
    {
        [TestMethod]
        public void ToAxisAngleTest()
        {
            Quaternion q = Quaternion.CreateFromAxisAngle(Vector3.Left, 1f);

            Vector3 axis;
            float angle;

            QuaternionExtensions.ToAxisAngle(ref q, out axis, out angle);

            AssertExtensions.AreEqual(Vector3.Left, axis);
            AssertExtensions.AreEqual(1f, angle);

            // Special case -- Identity should return z-axis
            q = Quaternion.Identity;
            QuaternionExtensions.ToAxisAngle(ref q, out axis, out angle);

            Assert.AreEqual(Vector3.UnitZ, axis);
            Assert.AreEqual(0f, angle);
        }

        [TestMethod]
        public void ToYawPitchRoll()
        {
            Quaternion q = Quaternion.CreateFromYawPitchRoll(
                MathHelper.ToRadians(10), 
                MathHelper.ToRadians(20), 
                MathHelper.ToRadians(30));

            float yaw, pitch, roll;

            QuaternionExtensions.ToYawPitchRoll(ref q, out yaw, out pitch, out roll);

            AssertExtensions.AreEqual(MathHelper.ToRadians(10), yaw);
            AssertExtensions.AreEqual(MathHelper.ToRadians(20), pitch);
            AssertExtensions.AreEqual(MathHelper.ToRadians(30), roll);
        }
    }
}
